/* Copyright 2012 Dustin Mitchell <dmmitche [at] gmail [dot] com>
 *
 * Licensed under the GPLv3.  See included LICENSE.txt for full details.
 */

#include <stdio.h>
#include <unistd.h>

#include "sysfs.h"

int sysfs_write_int (int fd, int val)
{
  char buff[16];
  int nchar = snprintf (buff, 16, "%d", val);

  if (fd == -1)
    return -1;

  if (write (fd, buff, nchar) != nchar)
    return -1;

  return 0;
}
